﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CGOnline.Server.Core
{
    public class RestrictStateObject:StateObject
    {
        AccessRestrictions _ar;
        public RestrictStateObject(AccessRestrictions ar)
        {
            _ar = ar;
        }
        protected void AccessValid(string methodname, AccessType accesstype)
        {
            if(!CanAccess(methodname, accesstype))
                throw new Exception(string.Format("Access {0}({1}) denied.",methodname,accesstype));
        }
        public bool CanAccess(string methodname,AccessType accesstype)
        {
            if (_ar == null)
                return false;
            return _ar.CheckAccess(this, methodname, accesstype);
        }
    }
}
